import Vue from "vue";
import App from "./App";
import store from "./store";
import {
	toast,
	px2rpx,
	getImageUri,
	copy,
	getParent
} from "./utils/tools";

// import uma from "./utils/umtrack-wx";
import Cache from "./utils/cache";
import uView from "@/components/uview-ui";
import minxinsApp from "@/mixins/app";
import MescrollBody from "@/components/mescroll-uni/mescroll-body.vue";
import routerLink from "./js_sdk/hhyang-uni-simple-router/link.vue";
import {
	router,
	RouterMount
} from "./router";
import request from '@/api/request.js'
Vue.prototype.$request = request;
import * as navTo from '@/api/navto.js';
Vue.prototype.$navto = navTo;
Vue.component("mescroll-body", MescrollBody);
Vue.prototype.$toast = toast;
Vue.prototype.$Cache = Cache;
Vue.prototype.$px2rpx = px2rpx;
Vue.prototype.$getImageUri = getImageUri;
Vue.prototype.$copy = copy;
Vue.prototype.$getParent = getParent;
Vue.config.productionTip = false;
Vue.component("RouterLink", routerLink);

Vue.use(router);
Vue.mixin(minxinsApp);
Vue.use(uView);
// uma.init({
// 	appKey: '66c2ff4c192e0574e76506a8',
// 	//umnAppKey即友盟给出的appkey
// 	// 使用Openid进行统计，此项为false时将使用友盟+uuid进行用户统计。
// 	// 使用Openid来统计微信小程序的用户，会使统计的指标更为准确，对系统准确性要求高的应用推荐使用Openid。
// 	useOpenid: true,
// 	// 使用openid进行统计时，是否授权友盟自动获取Openid，
// 	// 如若需要，请到友盟后台"设置管理-应用信息"(https://mp.umeng.com/setting/appset)中设置appId及secret
// 	autoGetOpenid: true,
// 	debug: false, //是否打开调试模式
// 	uploadUserInfo: true ,// 自动上传用户信息，设为false取消上传，默认为false
// 	enableVerify:true
// });
// uma.install = function(Vue) {
// 	Vue.prototype.$uma = uma;
// };
// Vue.use(uma);
App.mpType = "app";
const app = new Vue({
	...App,
	store,
});
Vue.prototype.$splitStr = function(str) {
	var parts = str.split(" ");
	console.log(parts);
	return parts[0];
}
Vue.prototype.$switchTab = function(url) {
	if (!this.isLogin) return this.$Router.push('/pages/login/login')
	uni.switchTab({
		url: url
	});
}
// 跳转小程序
Vue.prototype.$toMini = function(path) {
	wx.navigateToMiniProgram({
		appId: 'wx0c481a2b7105cdce',
		path: path,
		envVersion: 'release',
		success(res) {
			console.log("跳转小程序成功！", res);
		}
	})
}
Vue.prototype.$switchTab1 = function(url) {
	uni.setStorageSync('goodType', 2);
	uni.switchTab({
		url: url
	});
}
Vue.prototype.$teacher = function(arr) {
	let newArr = [];
	for (let i = 0; i < arr.length; i++) {
		newArr.push(arr[i].name);
	}
	return newArr.join('/');
}
Vue.prototype.$openCuster = function() {
	// 
	console.log("跳转客服");
	// uni.navigateTo({
	//     url: '/user/business_wechat/business_wechat'
	// })
	wx.openCustomerServiceChat({
		extInfo: {
			url: "https://work.weixin.qq.com/kfid/kfc645249b0fffeb1ca"
		},
		corpId: "ww64696a3c34f36304",
		fail(res) {
			console.log(res)
		}
	});
}
//v1.3.5起 H5端 你应该去除原有的app.$mount();使用路由自带的渲染方式
// #ifdef H5
RouterMount(app, router, "#app");
// #endif

// #ifndef H5
app.$mount(); //为了兼容小程序及app端必须这样写才有效果
// #endif